<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>管理员注册界面</title>
    <link rel="stylesheet" href="../js/bootstrap3/css/bootstrap.min.css">
    <link rel="stylesheet" href="../js/bootstrap-treeview/bootstrap-treeview.min.css">
    <link rel="stylesheet" href="../js/bootStrap-addTabs/bootstrap.addtabs.css">
    <link rel="stylesheet" href="../js/bootstrap-table/bootstrap-table.min.css">
    <link rel="stylesheet" href="../js/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css">
    <link rel="stylesheet" href="../js/bootstrap-fileinput/css/fileinput.min.css">
    <link rel="stylesheet" href="../js/kindeditor-4.1.10/themes/default/default.css"/>
</head>
<script type="text/javascript" src="../js/jquery-3.6.0.min.js"></script>
<script type="text/javascript" src="../js/bootstrap3/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../js/bootstrap-treeview/bootstrap-treeview.min.js"></script>
<script type="text/javascript" src="../js/bootStrap-addTabs/bootstrap.addtabs.min.js"></script>
<script type="text/javascript" src="../js/bootstrap-table/bootstrap-table.min.js"></script>
<script type="text/javascript" src="../js/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script type="text/javascript" src="../js/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="../js/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
<script type="text/javascript" src="../js/bootstrap-bootbox/bootbox.js"></script>
<script type="text/javascript" src="../js/bootstrap-fileinput/js/fileinput.min.js"></script>
<script type="text/javascript" src="../js/bootstrap-fileinput/js/locales/zh.js"></script>
<script type="text/javascript" src="../js/kindeditor-4.1.10/kindeditor-all.js"></script>
<body>

<!-- container-fluid 流式布局 -->
<div class="container-fluid">
    <form id="addForm" class="form-horizontal">

        <div class="row" th:each="guanggao:${guanggaoList}">
            <hr/>
            <div class="col-xs-12">
                <input type="button" value="替换轮播一号广告位" th:if="${guanggao.guanggaoid==1}" onclick="openUpdateGuanggao(1)" class="btn btn-sm btn-success"/>
                <input type="button" value="替换轮播二号广告位" th:if="${guanggao.guanggaoid==2}" onclick="openUpdateGuanggao(2)" class="btn btn-sm btn-success"/>
                <br/><br/>

                <img th:src="@{${guanggao.guanggaoimg}}" alt="广告罢工了！" height="350px">

            </div>
        </div>

    </form>
</div>

</body>
<script type="text/javascript">

    /*
  修改开始
   */
    //打开修改浮动页面
    function openUpdateGuanggao(guanggaoid){
        bootbox.dialog({
            size:"big",		//设置浮动页面大小 small-小	big-大
            title:"替换轮播图片",
            message:createUpdateGuanggao("../backstage/toUpdateGuanggao?guanggaoid="+guanggaoid),
            closeButton:true,	//是否显示取消按钮，右上角的
            buttons:{
                'success':{
                    "label":"<i class='icon-ok'></i>提交",
                    "className":"btn-sm btn-success",
                    "callback":function(){
                        $.ajax({
                            url:"../backstage/updateGuanggao",
                            type:"post",
                            data:$("#updateForm").serialize(),
                            success:function(data){
                                alert("恭喜你，修改成功！")
                                window.top.location.href="../backstage/index";
                                //$("#myTable").bootstrapTable("refresh");
                            },error:function(){
                                alert("修改失败！");
                            }
                        })
                    }
                },
                'cancle':{
                    "label":"<i class='icon-info'></i>取消",
                    "className":"btn-sm btn-danger",
                    "callback":function(){

                    }
                }
            }
        })
    }

    //创建修改页面
    var res;
    function createUpdateGuanggao(url){
        $.ajax({
            url: url,
            async:false,
            success:function(data){
                res=data;
            }
        })
        return res;
    }


</script>
</html>